﻿//JumbotCms_4.1 Final
using System;
using System.Data;
using System.Web;
using Jumbot.Common;
using Jumbot.DataOper;
namespace JumbotCms.DataObject
{
    /// <summary>
    /// 非法IP表信息
    /// </summary>
    public class ForbidIP
    {
        private string m_Id = "0";
        private float m_StartIP = 0;
        private float m_EndIP = 0;
        private DateTime m_ExpireDate = DateTime.Now;

        public string Id
        {
            get { return m_Id; }
            set { m_Id = value; }
        }
        public float StartIP
        {
            set { m_StartIP = value; }
            get { return m_StartIP; }
        }
        public float EndIP
        {
            set { m_EndIP = value; }
            get { return m_EndIP; }
        }
        public DateTime ExpireDate
        {
            set { m_ExpireDate = value; }
            get { return m_ExpireDate; }
        }

        public ForbidIP()
        {}
        public void GetAllColumn(string _id, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT * FROM [jcms_normal_forbidip] WHERE [Id]=" + _id;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                DataRow dr = dt.Rows[0];
                Id = _id;
                StartIP = Convert.ToSingle(dr["StartIP"]);
                EndIP = Convert.ToSingle(dr["EndIP"]);
                ExpireDate = Validator.StrToDate(dr["ExpireDate"].ToString(), DateTime.Now);
            }
        }

        public float GetStartIP(string _id, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT [StartIP] FROM [jcms_normal_forbidip] WHERE [Id]=" + _id;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                return Convert.ToSingle(dt.Rows[0]["StartIP"]);
            }
            return 0;
        }
        public float GetEndIP(string _id, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT [EndIP] FROM [jcms_normal_forbidip] WHERE [Id]=" + _id;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                return Convert.ToSingle(dt.Rows[0]["EndIP"]);
            }
            return 0;
        }
        public DateTime GetExpireDate(string _id, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT [ExpireDate] FROM [jcms_normal_forbidip] WHERE [Id]=" + _id;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                return Validator.StrToDate(dt.Rows[0]["ExpireDate"].ToString(), DateTime.Now);
            }
            return DateTime.Now;
        }

    }
}
